package org.pybaldaj.logic;

/**
 * Class handles game player.
 * @author akademi4eg
 *
 */
public class Player implements Comparable<Player> {

	public Player (int a_id)
	{
		id = a_id;
		is_info_loaded = false;
		score = 0;
	}
	
	public void loadInfo (Info a_info)
	{
		nickname = a_info.nickname;
		rank = a_info.rank;
		is_info_loaded = true;
	}
	
	public int getId ()
	{
		return id;
	}
	
	public int getScore ()
	{
		return score;
	}
	
	public void addToScore (int addition)
	{
		score += addition;
	}
	
	public String getNickname () throws DataIsNotLoaded
	{
		if (!is_info_loaded)
			throw new DataIsNotLoaded("Data is not");
		return nickname;
	}
	
	public int getRank () throws DataIsNotLoaded
	{
		if (!is_info_loaded)
			throw new DataIsNotLoaded("Data is not");
		return rank;
	}
	
	public int compareTo(Player pl) {
		return score - pl.score;
	}
	
	class Info {
		String nickname;
		int rank;
	}
	
	private int id;
	private String nickname;
	private int rank;
	private int score;
	private boolean is_info_loaded;
}
